package co.za.alacrity.gui;

import java.awt.Color;
import java.awt.Color;
import java.awt.GridLayout;
import java.util.Observable;
import java.util.Observer;
import javax.swing.BorderFactory;
import javax.swing.JPanel;

import co.za.alacrity.obseverpattern.TextFieldListener;

public class SudokuPanel extends JPanel{
	
	  private static final Color COLOR_CANDIDATE = new Color(102, 153, 255);

	   private TextFields[][] fields;       // Array of fields.
	    private JPanel[][] panels;      // Panels holding the fields.

	    /**
	     * Constructs the panel, adds sub panels and adds fields to these sub panels.
	     */
	    public SudokuPanel(TextFieldListener owner) {
	        super(new GridLayout(3, 3));

	        panels = new JPanel[3][3];
	        for (int y = 0; y < 3; y++) {
	            for (int x = 0; x < 3; x++) {
	                panels[y][x] = new JPanel(new GridLayout(3, 3));
	                panels[y][x].setBorder(BorderFactory.createLineBorder(Color.DARK_GRAY));
	                add(panels[y][x]);
	            }
	        }

	        fields = new TextFields[9][9];
	        for (int y = 0; y < 9; y++) {
	            for (int x = 0; x < 9; x++) {
	                fields[y][x] = new TextFields(x, y,owner);
	                panels[y / 3][x / 3].add(fields[y][x]);
	            }
	        }
	    }
	    
	    public void setValue(int r,int c,int v){
	    	fields[r][c].setValue(v);
	    }

		public void setBold(int r, int k, boolean b) {
			fields[r][k].setBold(b);
		}
	
	    
	    
	

}
